package cn.edu.scau.service.impl;

import cn.edu.scau.dao.NurseMapper;
import cn.edu.scau.entity.Nurse;
import cn.edu.scau.service.NurseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class NurseServiceImpl implements NurseService {
    @Autowired
    NurseMapper nurseMapper;
    @Override
    public List<Nurse> selectAll() {
        return nurseMapper.selectAll();
    }

    @Override
    public boolean updateByPrimaryKey(Nurse record) {
        return false;
    }

    @Override
    public boolean insert(Nurse record) {
        int line = nurseMapper.insert(record);
        return line ==1? true:false;
    }

    @Override
    public boolean deleteByPrimaryKey(Integer nurseid) {
        int line = nurseMapper.deleteByPrimaryKey(nurseid);
        return line ==1? true:false;
    }

    @Override
    public Nurse selectByPrimaryKey(Integer nurseid) {
        return nurseMapper.selectByPrimaryKey(nurseid);
    }

    @Override
    public Nurse selectByUserId(Integer userid) {
        return nurseMapper.selectByUserId(userid);
    }

    @Override
    public boolean updateByPrimaryKeySelective(Nurse record) {
        int line = nurseMapper.updateByPrimaryKeySelective(record);
        return line ==1? true:false;
    }

    @Override
    public List<Nurse> findByIdUseidName(Integer userId, Integer nurseID, String nursename) {
        if(nurseID!=null){
            if(nurseID<1)
                return null;
        }
        if(userId!=null){
            if(userId<1)
                return null;
        }
        return nurseMapper.findByIdUseidName(nurseID, userId, nursename);
    }
}
